<?php
include 'database.php'; //数据库的配置信息
require 'lianjie.php';  // 数据库的操作函数
$con = lianjieshujuku($servername, $name, $passwd);//连接数据库
$username = $_GET['username'];
if (!mysqli_select_db($con, 'floweruser')) {
    die("选择数据库失败");
}
$req = mysqli_query($con, "select * from `user` WHERE `username`= '$username'");
$m = mysqli_fetch_array($req);
$arry = explode('|', $m['flowers']);


foreach ($arry as $mac) {
    if (!mysqli_select_db($con, 'flower')) {
        die("选择数据库失败");
    }
    $req = mysqli_query($con, "select * from `fname` WHERE `mac`= '$mac'");
    $m[$mac]=mysqli_fetch_array($req)['macname'];
}
echo json_encode($m);
//if (!mysqli_select_db($con, 'flower')) {
//    die("选择数据库失败");
//}

//
//$req = mysqli_query($con,"select * from `fname` WHERE `mac`= '121212121212'");
//$m2 = mysqli_fetch_array($req);
//
//$m['121212121212']=$m2['macname'];
//$req = mysqli_query($con,"select * from `fname` WHERE `mac`= 'ACCF233B5B72'");
//$m2 = mysqli_fetch_array($req);
//
//$m['ACCF233B5B72']=$m2['macname'];

//echo json_encode($m);
//echo json_decode(json_encode($m),true)['121212121212'];
